package com.wedata.海康云;

import cn.hutool.json.JSONObject;
import com.wedata.HttpUtils;

public class 人员分组 extends BaseService{

    public static void main(String[] args) {
        //addPerson();
        //removePerson();
        queryPersonByGroup();
    }

    /**
     * 通过分组查询人员信息
     * @return
     */
    public static String queryPersonByGroup(){
        JSONObject param = new JSONObject();
        param.set("projectId",projectId);
        param.set("productCode",productCode);
        param.set("pageNo",1);
        param.set("pageSize",100);
        //param.set("groupId",2165211671547568L);//安装人员上传的照片
        //{"msg":"","code":"200","data":{"pageSize":10,"list":["2094084777455280","2164772650077872","2165522994286256"],"total":3,"pageNo":1}}
        param.set("groupId","563131970044840");
        JSONObject header = new JSONObject("{\"access_token\":\""+getToken()+"\"}");
        JSONObject jsonObject = HttpUtils.sendPost("https://open.hikyun.com/artemis/api/eits/fdcs/v1/personGroup/person/page",header,param);


        System.out.println(jsonObject);
        return jsonObject.toString();
    }

    /**
     * 查询人员分组
     * @return
     */
    public static String queryPersonGroup(){
        JSONObject param = new JSONObject();
        param.set("projectId",projectId);
        param.set("productCode",productCode);
        param.set("pageNo",1);
        param.set("pageSize",100);
        JSONObject header = new JSONObject("{\"access_token\":\""+getToken()+"\"}");
        JSONObject jsonObject = HttpUtils.sendPost("https://open.hikyun.com/artemis/api/eits/fdcs/v1/personGroup/page",header,param);

        System.out.println(jsonObject);
        return jsonObject.toString();
    }

    /**
     * 添加人员分组
     * @return
     */
    public static String addGroup(){
        JSONObject param = new JSONObject();
        param.set("projectId",projectId);
        param.set("productCode",productCode);
        param.set("groupName","约课调研组");
        System.out.println(param);
        JSONObject header = new JSONObject("{\"access_token\":\""+getToken()+"\"}");
        JSONObject jsonObject = HttpUtils.sendPost("https://open.hikyun.com/artemis/api/eits/fdcs/v1/personGroup/add",header,param);

        //{"msg":"","code":"200","data":{"groupId":"563131970044840"}}
        System.out.println(jsonObject);
        return null;
    }
    /**
     * 删除分组中的人员
     * @return
     */
    public static String removePerson(){
        JSONObject param = new JSONObject();
        param.set("projectId",projectId);
        param.set("productCode",productCode);
        param.set("groupId","563131970044840");
        param.set("personIds", new String[]{"792996529064"});
        System.out.println(param);
        JSONObject header = new JSONObject("{\"access_token\":\""+getToken()+"\"}");
        JSONObject jsonObject = HttpUtils.sendPost("https://open.hikyun.com/artemis/api/eits/fdcs/v1/personGroup/person/delete",header,param);

        //{"msg":"","code":"200","data":null}
        System.out.println(jsonObject);
        return null;
    }
    /**
     * 添加人员到分组
     * @return
     */
    public static String addPerson(){
        JSONObject param = new JSONObject();
        param.set("projectId",projectId);
        param.set("productCode",productCode);
        param.set("groupId","563131970044840");
        param.set("personIds", new String[]{"792996529064"});
        System.out.println(param);
        JSONObject header = new JSONObject("{\"access_token\":\""+getToken()+"\"}");
        JSONObject jsonObject = HttpUtils.sendPost("https://open.hikyun.com/artemis/api/eits/fdcs/v1/personGroup/person/add",header,param);

        //{"msg":"","code":"200","data":null} -- 重复提交好像没反应--无影响
        System.out.println(jsonObject);
        return null;
    }
}
